# 集合：元素无序，且不重复
# 变量名称={元素1，元素2，元素3，……}
# 集合不支持下标索引访问


m_set = {1, 2, 3, 4, 5}
m_set1={}
print(f"m_set={{}}的类型为{type(m_set)}")
print(m_set)
print(type(m_set))

# add
m_set.add("666")
print(m_set)
m_set.add(5)
print(m_set)

# remove
m_set.remove("666")
print(m_set)

# pop
ret1 = m_set.pop()
print(f"被删除元素为{ret1}")
print(m_set)

# clear
m_set.clear()
print(m_set)

# difference 取差集，离散数学中的相对补
set1 = {1, 2, 3}
set2 = {2, 3, 4}
ret2 = set1.difference(set2)
print(ret2)

# difference_update 消除集合差集
ret3 = set1.difference_update(set2)
print(ret3)
print(set1)
print(set2)

# union 合并
set1 = {1, 2, 3}
set2 = {2, 3, 4}
ret4 = set1.union(set2)
print(ret4)

# len
length=len(ret4)
print(length)
